// 用户路由
const express = require('express');
const router = express.Router();
const UserController = require('../controllers/userController');
const { authMiddleware, teacherMiddleware } = require('../utils/authMiddleware');

/**
 * 用户路由
 * 定义用户相关的API端点
 */

// 公开路由
router.post('/login', UserController.login);

// 需要认证的路由
router.get('/info', authMiddleware, UserController.getUserInfo);
router.post('/change-password', authMiddleware, UserController.changePassword);

// 教师专用路由
router.post('/register', authMiddleware, teacherMiddleware, UserController.register);
router.delete('/:userId', authMiddleware, teacherMiddleware, UserController.deleteUser);
router.get('/students', authMiddleware, teacherMiddleware, UserController.getStudents);
router.post('/:userId/reset-password', authMiddleware, teacherMiddleware, UserController.resetPassword);

module.exports = router;